package com.richapp.launcher.net.box.tcp.client;

import com.jack.netty.tcp.client.TLVClient;
import com.jack.netty.tcp.client.TLVClientListener;
import com.jack.netty.tcp.server.ServerSessionManager;
import com.richapp.launcher.net.box.tcp.server.BoxServer;

/**
 * Created by jack on 2015/5/5 0005.
 */
public class BoxClient extends TLVClient implements TLVClientListener {

    private String boxCpuId;


    public BoxClient(){
        setTlvClientListener(this);
    }

    @Override
    public void onConnect(String serverId) {
        ServerSessionManager.add(serverId, getServerChannelHandlerContext());
        BoxServer.getInstance().doConnectBox(serverId, true);
    }

    @Override
    public void onDisconnect(String serverId) {
        ServerSessionManager.del(serverId);
        BoxServer.getInstance().doBoxOffline(serverId);
    }

    @Override
    public void onMessage(String serverId,String message) {
        BoxServer.getInstance().preDoMessage(serverId,message);
    }

    public String getBoxCpuId() {
        return boxCpuId;
    }

    public void setBoxCpuId(String boxCpuId) {
        this.boxCpuId = boxCpuId;
    }

}
